package com.kudostar.android.kudostar;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Menu.Item;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * @author Mike Luby
 * 
 */
public class KudoList extends ListActivity {

	private List<String> items = null;
	KudoCommon kc = new KudoCommon( );

	private void fill( ) {
		items = new ArrayList<String>();
		for( int i = 0; i < 100; i++ ) {
			items.add( "Kudo: " + i );
		}
		ArrayAdapter<String> kudoList = new ArrayAdapter<String>(this, R.layout.file_row, items);
		setListAdapter( kudoList );
	}
	public void onCreate(Bundle icicle) {
		super.onCreate( icicle );
		Globals.list_type = 1;
		setContentView( R.layout.view_list );
		fill( );
		findViewById( R.id.view_home ).setOnClickListener( new View.OnClickListener( ) {
			public void onClick(View view) {
				finish( );
			}
		} );
		findViewById( R.id.view_map ).setOnClickListener( new View.OnClickListener( ) {
			public void onClick(View view) {
				/**
				 * Show Client's KudoStars in list format
				 */
				startActivity( new Intent( KudoList.this, KudoMap.class ) );
			}
		} );
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu( menu );
		return this.kc.BuildMenu( menu );
	}
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
	    // TODO Auto-generated method stub
	    super.onListItemClick( l, v, position, id );
	    showAlert( "Kudo", "kudo: " + position, "ok", null, false, null );
    }

	@Override
	public boolean onOptionsItemSelected(Item item) {
		return this.kc.MenuOptionSelect( this, item );
	}
}